/*
	将本app.js放入项目根木中，
	运行电脑DOS程序，通过windows命令进入当前文件夹
	输入以下命令，按照必要运行包：
		>cnpm install express --save
		>cnpm install body-parser --save
		>cnpm install uuid --save
		>cnpm install jsonwebtoken --save
		>cnpm install svg-captcha --save
	安装完毕后，运行以下命令，启动服务器运行当前后端程序：
		>node app.js
		
	一旦文件有修改，需要停止服务器：在DOS中，快捷键： Ctrl+C
	然后再运行命令重启服务器：>node app.js

*/
////////////////////////////////////////////////////////////////////


//导入Express框架
var Express = require('express');
//导入报文解析
var bodyparser = require('body-parser');
//导入UUID模块 - 用于生成一个唯一的id值
const UUID = require('uuid');
//导入令牌 - 登录状态及单点登录
const jwt = require('jsonwebtoken');
//导入crypto库-md5加密技术
var crypto = require('crypto');  


//实例化Express对象
var app = new Express();


//设置与配置
//设置报文编码格式
//针对：enctype="appliction/x-www-form-urlencoded"
var urlencodedparser = bodyparser.urlencoded({extended:false});
//设置接收内容支持json
app.use(bodyparser.json());


//设置允许跨域访问
app.all("*",function(req,res,next){
    //设置允许跨域的域名，*代表允许任意域名跨域
    res.header("Access-Control-Allow-Origin","*");
    //允许的header类型
    res.header("Access-Control-Allow-Headers","content-type");
    //跨域允许的请求方式 
    res.header("Access-Control-Allow-Methods","DELETE,PUT,POST,GET,OPTIONS");
    if (req.method.toLowerCase() == 'options')
        res.send(200);  //让options尝试请求快速结束
    else
        next(); //放行
})


// 创建http监听服务：8888端口
var server = app.listen(8888,function(){
	//需要的指令代码段
	console.log('=====【API服务器启动】=====')
});


//===============================================================



//用户登录
app.post('/login',function(request,response){
	console.log(request.body)
	let username = request.body.username;
	let userpass = request.body.userpass;
	
	//过滤数据，防止有特殊内容
	//密码是否需要加密 -- 前端已经加密了，这里不用了
	//组合sql语句，查询数据库，看有没有查询结果
	//这里只是一个测试：
	// username = 'admin123'
	// userpass = 'e10adc3949ba59abbe56e057f20f883e' //123456	
	if(username=='admin123' && userpass=='123456'){
		
		//有的，查询到了
		//第一步：设置约定令牌加密解密的key：自定义，必须和客户端对应
		const key = 'bwf-key';
		
		//第二步：装载数据：这就是令牌中的信息，要回发客户端的
		//		 里面包括：数据，令牌时效
		//		 user是当前登录用户的信息
		//		 expires固定的，定义令牌时效，从当前开始，追加多少，按照秒计算
		const payload = {
			user: {
				userid:1,
				username:'admin123',
				//userpass:'e10adc3949ba59abbe56e057f20f883e' //去除掉
				// nickname:'葫芦娃',
			},
			expires: Date.now()+1000*60*60*24
		};
		
		//第三步：生成令牌(装载的数据，密钥)
		let token = jwt.sign(payload,key);
		
		//第四步：回发客户端:回发的json对象
		response.send({'code':200,'msg':'登录成功', 'data':token});
		
	}
	else{
		//没有:回发一个
		response.send({'code':400,'msg':'登录失败'});
	}
});

//手机号是否存在
app.get('/verification',function(request,response){
	let phone = request.query.phone
	// console.log(phone)
	//存在138909098080
	if(phone == '13890908080'){
		response.send({'code':200,'msg':'success'})
	}else{
		response.send({'code':400,'msg':'该手机号不存在'})
	}
});

//获取验证码
app.get('/getVerification',function(request,response){
	let phone = request.query.phone
	const code = Math.floor(100000+Math.random() * 900000);
	console.log(`【短信】验证码：${code}，5分钟内有效，请勿泄露。`);
	response.send({'code':200,'msg':'success','data':code})
});

//更新密码
app.put('/updatePass',function(request, response){
	let phone = request.body.phone;
	let userpass = request.body.userpass;
	//查找phone
	//更新phone的密码
	response.send({'code':200,'msg':'success','data':''})
});

//获取轮播图
app.get('/getSwiper',function(request, response){
	let data = [
		'https://cdn8.axureshop.com/demo2025/2105401/images/%E7%99%BB%E5%BD%95%E9%A1%B5/u47.svg',
		'https://ts1.tc.mm.bing.net/th/id/R-C.987f582c510be58755c4933cda68d525?rik=C0D21hJDYvXosw&riu=http%3a%2f%2fimg.pconline.com.cn%2fimages%2fupload%2fupc%2ftx%2fwallpaper%2f1305%2f16%2fc4%2f20990657_1368686545122.jpg&ehk=netN2qzcCVS4ALUQfDOwxAwFcy41oxC%2b0xTFvOYy5ds%3d&risl=&pid=ImgRaw&r=0',
		'https://cdn8.axureshop.com/demo2025/2105401/images/%E7%99%BB%E5%BD%95%E9%A1%B5/u47.svg',
		'https://ts1.tc.mm.bing.net/th/id/R-C.987f582c510be58755c4933cda68d525?rik=C0D21hJDYvXosw&riu=http%3a%2f%2fimg.pconline.com.cn%2fimages%2fupload%2fupc%2ftx%2fwallpaper%2f1305%2f16%2fc4%2f20990657_1368686545122.jpg&ehk=netN2qzcCVS4ALUQfDOwxAwFcy41oxC%2b0xTFvOYy5ds%3d&risl=&pid=ImgRaw&r=0'
	]
	response.send({'code':200,'msg':'success','data':data})
});
/*
 app.?('?',function(request, response){
 	response.send({'code':200,'msg':'success','data':})
 });
 */

//实例：定义一个简单的get请求接口
//get表示请求方式
//第一个参数：接口名称
//第二个参数：处理的匿名方法
//	方法中有默认传入2个对象
//	第一个对象：客户端请求的所有信息在里面
//	第二个对象：服务器响应对象，回发的内容都必须通过它
app.get('/test',function(request, response){
	//没有数据的，就响应一下
	console.log('调用')

	//借口可以用,但是返回结果必须是这个格式
	//data可以返回json对象，鸿蒙里面自己对应写约束类型,否则转不出来
	//code 和 msg 不能动
	//还有,这里的get请求,是没有data参数的,
	//自己将数据组合到地址中,是地址的一部分
	//有点像我们司机项目中,任务详情的借口请求一样 `/aaaa/${}/${}` 这种格式,要你自己组合的
	response.send({'code':200,'msg':'登录成功', 'data':'调用成功'});
});




//测试:get请求，路径传参数，只能一个，默认用id接收,要多个参数,自己写,
//http://localhost:8888/text_get/555
app.get('/test_get/:id/:age/:sex',function(request,response){
	//从请求对象中，参数集合里面，获取参数id
	let id = request.params.id;
	//返回一个json，交给前端
	response.send({'id':id});
});


//客户端浏览器post提交的数据，是报文
//方法需要中间加入一个参数，报文处理
app.post('/test_post',function(request,response){
	//从请求对象的报文数据中，获取指定名称的参数
	let username = request.body.username;
	//返回处理结果
	response.send({'postvalue':username});
	
});


//满足restFull格式，还有两种请求：
// put：针对表单提交，执行update更新数据操作的
app.put('/test_put',urlencodedparser,function(request,response){
	let username = request.body.username;
	response.send({'更新名称是':username});
	
});


// delete：针对路径提交，执行delete删除操作的
app.delete('/test_delete/:id',function(request,response){
	let id = request.params.id;
	response.send({'需要删除的id是':id});
});










//加载依赖
const svgCaptcha = require('svg-captcha');
//绘制验证码方法
app.get('/createverify',function(request, response){
	//设置绘制参数
	const codeConfig = {
		width: 160,				//图片宽度
		height: 50,				//图片高度
		fontSize: 50,			//文本大小
		size: 4,				//验证码长度
		ignoreChars: '0Oo1l',	//默认是所有大写，小写，数字，这里是指定排除哪些
		noise: 3,				//干扰线条的数量
		color: true,			//验证码文本是否有颜色，默认false没有，如果设定图片背景颜色，自动变成true
		background:'#eeeeee'	//图片背景色
	};
	
	//绘制出图片代码
	const captcha = svgCaptcha.create(codeConfig);
	
	//在上面 captcha对象中，有两个重要参数
	//它是一个json格式
	// captcha.data		图片代码
	// captcha.text		验证码文本
	//把数据回发客户端，如果有时效的，需要时间
	//返回一个json：{img:'', code:'',time:''}
	//时间：10分钟有效
	let time = Date.now()+1000*60*10;
	response.send({
		'img':captcha.data, 
		'code':captcha.text.toLowerCase(), 
		'time':time});
});


//重名判断api接口
//get方式，传参数
app.get('/rname/:username',function(request, response){	
	//获取用户提交的用户名，过滤文本内容
	//组合语句，执行数据库查询
	//然后判断查询结果
	//这里只是测试一下
	let username = request.params.username;
	if(username=='admin123' || username=='aaaaaa' || username=='abc123'){
		response.send('1');//重名：有
	}else{
		response.send('0');//没有
	}
});


//用户注册：表单提交
app.post('/register',urlencodedparser,function(request,response){
	let username = request.body.username;
	let userpass = request.body.userpass;
	
	//第一步：设置约定令牌加密解密的key：自定义，必须和客户端对应
	const key = 'bwf-key';
		
	//第二步：装载数据：这就是令牌中的信息，要回发客户端的
	//		 里面包括：数据，令牌时效
	//		 user是当前登录用户的信息
	//		 expires固定的，定义令牌时效，从当前开始，追加多少，按照秒计算
	const payload = {
		user: {
			userid:555,
			username:'admin123',
			//userpass:'e10adc3949ba59abbe56e057f20f883e' //去除掉
			nickname:'葫芦娃',
		},
		expires: Date.now()+1000*60*60*24
	};
	
	//第三步：生成令牌(装载的数据，密钥)
	let token = jwt.sign(payload,key);
	
	//第四步：回发客户端
	response.send({'success':true,'token':token, nickname:'葫芦娃'});
});


//测试：得到md5加密内容
app.get('/md5/:value',function(request,response){	
	
	//单值加密技术
	var content = request.params.value;
	
	//有些项目，按照要求，可能会对密码进行重组加密
	//md5(密码+密码)  123456123456
	//content = request.params.value + request.params.value;
		
	var md5 = crypto.createHash('md5');
	md5.update(content);
	var d = md5.digest('hex');
	response.send(d);	
});

//验证令牌有效性：返回状态码
app.get('/validatetoken/:token',function(request,response){	
	//获取请求发送的令牌
	let token = request.params.token;
	//解密验证
	jwt.verify(token, 'bwf-key', function(error, decode){
		if(error){
			//解密失败，没有解密资源，用户没有登录
			//402		登录信息验证失败
			response.sendStatus(402);
		}else{
			//可以解密，说明登录了，令牌是否有效
			if(Date.now() > decode.expires){
				//登录超时
				//401		登录状态失效
				response.sendStatus(401);
			}else{
				//正常
				response.sendStatus(200);
			}
		}
	});

});



//按照口味和规格返回对应的商品列表信息
app.get('/getlist/:flavor/:specs',function(request,response){	
	
	let flavor = request.params.flavor;
	let specs = request.params.specs;
	
	if(flavor==-1 && specs==-1){
		response.send([
			{id:1,img:'http://localhost:8080/img/list_28444.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''},
			{id:2,img:'http://localhost:8080/img/list_28441.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'热卖新品',activity:''},
			{id:3,img:'http://localhost:8080/img/list_29096.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'招牌',activity:'周末庆生专享 赠盒子蛋糕'},
			{id:4,img:'http://localhost:8080/img/list_29383.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''},
			{id:5,img:'http://localhost:8080/img/list_29387.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'热卖商品',activity:''},
			{id:6,img:'http://localhost:8080/img/list_29392.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'热卖商品',activity:'周末庆生专享 赠盒子蛋糕'},
			{id:7,img:'http://localhost:8080/img/list_29403.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''},
			{id:8,img:'http://localhost:8080/img/list_29424.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'热卖商品',activity:''},
			{id:9,img:'http://localhost:8080/img/list_28686.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''},
			{id:10,img:'http://localhost:8080/img/list_28444.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:'周末庆生专享 赠盒子蛋糕'},
			{id:11,img:'http://localhost:8080/img/list_29089.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''},
			{id:12,img:'http://localhost:8080/img/list_12253.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''}
		]);
	}
	else if(flavor!=-1&&specs==-1){
		response.send([
			{id:1,img:'http://localhost:8080/img/list_28444.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''},
			{id:2,img:'http://localhost:8080/img/list_28441.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'热卖新品',activity:''},
			{id:3,img:'http://localhost:8080/img/list_29096.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'招牌',activity:'周末庆生专享 赠盒子蛋糕'},
			{id:4,img:'http://localhost:8080/img/list_29383.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''},
			{id:5,img:'http://localhost:8080/img/list_29387.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'热卖商品',activity:''},
			{id:6,img:'http://localhost:8080/img/list_29392.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'热卖商品',activity:'周末庆生专享 赠盒子蛋糕'},
			]);
	}
	else if(flavor==-1&&specs!=-1){
		response.send([
			{id:6,img:'http://localhost:8080/img/list_29392.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'热卖商品',activity:'周末庆生专享 赠盒子蛋糕'},
			{id:7,img:'http://localhost:8080/img/list_29403.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''},
			{id:8,img:'http://localhost:8080/img/list_29424.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'热卖商品',activity:''},
			{id:9,img:'http://localhost:8080/img/list_28686.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''},
			]);
	}
	else if(flavor==2&&specs==2){
		response.send('');//没有
	}
	else{
		response.send([
			{id:8,img:'http://localhost:8080/img/list_29424.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'热卖商品',activity:''},
			{id:9,img:'http://localhost:8080/img/list_28686.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''},
			{id:10,img:'http://localhost:8080/img/list_28444.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:'周末庆生专享 赠盒子蛋糕'},
			{id:11,img:'http://localhost:8080/img/list_29089.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''},
			{id:12,img:'http://localhost:8080/img/list_12253.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''}
		]);
	}
	
});

//按照id返回不同页面的商品列表
app.get('/goodslist/:id',function(request,response){	
	
	let id = request.params.id;
	
	//自定义ifelse，如果id==1
	if(id==1){
		//0轻享
		response.send([
			{id:1,img:'list_16196.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''},
			{id:2,img:'list_16196.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'热卖新品',activity:''},
			{id:3,img:'list_16196.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'招牌',activity:'周末庆生专享 赠盒子蛋糕'},
			{id:4,img:'list_16196.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''},
			{id:5,img:'list_16196.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'热卖商品',activity:''},
		]);
	}
	else if(id==2){
		//元气早餐
		response.send([
			{id:1,img:'list_16196.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''},
			{id:2,img:'list_16196.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'热卖新品',activity:''},
			{id:3,img:'list_16196.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'招牌',activity:'周末庆生专享 赠盒子蛋糕'},
			{id:4,img:'list_16196.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''},
			{id:5,img:'list_16196.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'热卖商品',activity:''},
		]);
	}
	else if(id==3){
		//甜点心礼
		response.send([
			{id:1,img:'list_16196.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''},
			{id:2,img:'list_16196.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'热卖新品',activity:''},
			{id:3,img:'list_16196.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'招牌',activity:'周末庆生专享 赠盒子蛋糕'},
			{id:4,img:'list_16196.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''},
			{id:5,img:'list_16196.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'热卖商品',activity:''},
		]);
	}
});


//接口：按照提供的id，获取商品列表
app.get('/getgoodslist/:ids',function(request,response){	
	
	let ids = request.params.ids;
	
	//测试：拱顶返回
	response.send([
		{id:1,img:'list_16196.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''},
		{id:2,img:'list_16196.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'热卖新品',activity:''},
	]);
	
});


//城市列表
app.get('/citylist',function(request,response){	
	response.send([
		{cityId:1, cityName:'上海'},
		{cityId:2, cityName:'北京'},
		{cityId:3, cityName:'广州'},
		{cityId:4, cityName:'深圳'},
		{cityId:5, cityName:'成都'},
		{cityId:6, cityName:'杭州'},
		{cityId:7, cityName:'无锡'},
		{cityId:8, cityName:'南京'},
		{cityId:9, cityName:'苏州'},
		{cityId:10, cityName:'石家庄'},
		{cityId:11, cityName:'天津'},
		{cityId:12, cityName:'宁波'},
		{cityId:555, cityName:'全国其他城市'}
	]);	
});


//NodeJS服务器开发：
app.get('/search/:keywords/:page', (request, response)=>{
	//获取路径参数
	const key = request.params.keywords
	const page = request.params.page

  
	if(page>=4){
		response.send([])
	}
	//判断模拟数据
	else if(key=='蛋糕' || key=='-1'){
		response.send([
			{id:1,img:'http://localhost:8080/img/list_28444.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''},
			{id:2,img:'http://localhost:8080/img/list_28441.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'热卖新品',activity:''},
			{id:3,img:'http://localhost:8080/img/list_29096.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'招牌',activity:'周末庆生专享 赠盒子蛋糕'},
			{id:4,img:'http://localhost:8080/img/list_29383.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''},
			{id:5,img:'http://localhost:8080/img/list_29387.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'热卖商品',activity:''},
			{id:6,img:'http://localhost:8080/img/list_29392.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'热卖商品',activity:'周末庆生专享 赠盒子蛋糕'},
			{id:7,img:'http://localhost:8080/img/list_29403.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''},
			{id:8,img:'http://localhost:8080/img/list_29424.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'热卖商品',activity:''},
			{id:9,img:'http://localhost:8080/img/list_28686.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''},
			{id:10,img:'http://localhost:8080/img/list_28444.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:'周末庆生专享 赠盒子蛋糕'},
			{id:11,img:'http://localhost:8080/img/list_29089.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''},
			{id:12,img:'http://localhost:8080/img/list_12253.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''},
		])
	}
	else if(key=='巧克力'){
		response.send([
			{id:1,img:'http://localhost:8080/img/list_28444.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''},
			{id:2,img:'http://localhost:8080/img/list_28441.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'热卖新品',activity:''},
			{id:3,img:'http://localhost:8080/img/list_29096.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'招牌',activity:'周末庆生专享 赠盒子蛋糕'},
			{id:4,img:'http://localhost:8080/img/list_29383.jpg',title:'雪域牛乳芝士丶特浓',info:'甄选澳洲进口全脂纯牛奶 浓醇升级',price:'298',bag:'',activity:''}
		])
	}
	else{
		response.send([])
	}
})